import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

//对没有padding属性的组件，可以使用padding组件来实现内边距，示例种的Image就没有padding属性
//自定义组件
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // MaterialApp是根组件
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(' grid view padding'),
        ),
        body: HomeContent(),
      ),
      theme: ThemeData(primaryColor: Colors.blue),
    );
  }
}

//body内容组件
class HomeContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GridView.count(
      crossAxisCount: 3,
      //子主件宽高比
      childAspectRatio: 1.7,
      children: <Widget>[
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
        Padding(
          padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
          child: Image.asset("images/independentmind.jpeg",
              alignment: Alignment.topCenter,
              // color: Colors.amber,
              colorBlendMode: BlendMode.luminosity,
              fit: BoxFit.cover),
        ),
      ],
    );
  }
}
